package com.cf.r1045;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class b {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int T = Integer.parseInt(br.readLine());
        while (T-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        long k = Long.parseLong(in[1]);
        long d = k + 1;
        in = br.readLine().split(" ");
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(in[i]);
        }
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < n; i++) {
            long t = a[i] % d;
            long x = a[i] + t * k;
            ans.append(x);
            if (i + 1 < n) ans.append(" ");
        }
        out.println(ans);

    }
}
